﻿@model NetSurveillance.WebApp.Models.SaveAccountModel
@{
    ViewBag.Title = Model != null && Model.Id.HasValue ? Resources.Resource.AlterAcct : Resources.Resource.CreateAcct;
    Layout = "~/Views/Shared/_SystemConfigLayout.cshtml";
    ViewBag.CurrentMiddleMenu = 7;
    ViewBag.CurrentMainMenu = 5;
}
@section css{
    <style type="text/css">
        .inline-form {
            width: 75%;
            margin: 20px auto;
        }
    </style>
}
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true, Resources.MessageResource.AcctCreateUnSuccInfo)
    @Html.ValidationMessage("PasswordIncorrect")
    <div>
        <fieldset class="inline-form">
            <legend>@Resources.ViewResource.SaveAcct_AcctInfo</legend>

            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.UserName)
                </div>
                <div class="editor-field">
                    @(Model!=null&&Model.Id.HasValue ? Html.TextBox("disabled_account",Model.UserName, new {disabled = "disabled"}) : Html.TextBoxFor(m => m.UserName))
                    @if (Model != null && Model.Id.HasValue)
                    {
                        @Html.HiddenFor(m => m.UserName)
                    }
                    @Html.ValidationMessageFor(m => m.UserName)
                </div>
            </div>
            @if (Model != null && Model.Id.HasValue)
            {
                <div class="editor-entry">
                    <div class="editor-label">
                        @Html.LabelFor(m => m.OldPassword)
                    </div>
                    <div class="editor-field">
                        @Html.PasswordFor(m => m.OldPassword)
                        @Html.ValidationMessageFor(m => m.OldPassword)
                    </div>
                </div>
            }
            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.NewPassword)
                </div>
                <div class="editor-field">
                    @Html.PasswordFor(m => m.NewPassword)
                    @Html.ValidationMessageFor(m => m.NewPassword)
                </div>
            </div>
            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.ConfirmNewPassword)
                </div>
                <div class="editor-field">
                    @Html.PasswordFor(m => m.ConfirmNewPassword)
                    @Html.ValidationMessageFor(m => m.ConfirmNewPassword)
                </div>
            </div>
            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.RealName)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.RealName)
                    @Html.ValidationMessageFor(m => m.RealName)
                </div>
            </div>
            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.Email)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.Email)
                    @Html.ValidationMessageFor(m => m.Email)
                </div>
            </div>
            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.Phone)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.Phone)
                    @Html.ValidationMessageFor(m => m.Phone)
                </div>
            </div>
            <div class="editor-entry">
                <div class="editor-label">
                    @Html.LabelFor(m => m.UserType)：
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(m => m.UserType, 
                                          new[]
                                              {
                                                  new SelectListItem { Text = Resources.ModelResource.UserType_Normal, Value = "1" }, 
                                                  new SelectListItem { Text = Resources.ModelResource.UserType_Admin, Value = "0" }
                                              }, (ViewBag.IsAdmin ?? false) ? null : new { disabled = "disabled" })
                </div>
            </div>
            <div class="editor-entry" style="@((ViewBag.IsAdmin ?? false) ? "" : "display:none;")">
                <div class="editor-label">
                    @Html.LabelFor(m => m.HaveDeletePms)
                </div>
                <div class="editor-field">
                    <label>
                        @Html.RadioButtonFor(m => m.HaveDeletePms, true)
                        @Resources.Resource.Yes
                    </label>
                    <label>
                        @Html.RadioButtonFor(m => m.HaveDeletePms, false)
                        @Resources.Resource.No
                    </label>
                    @Html.ValidationMessageFor(m => m.HaveDeletePms)
                </div>
            </div>
            @Html.HiddenFor(m => m.Id)
            <div class="buttonsContain controlBottom">
                <div class="rightContain">
                    <input type="submit" value="@Resources.Resource.Button_Save" />
                    <input id="btnBack" type="button" value="@Resources.Resource.Button_Back"/>
                </div>
            </div>
        </fieldset>
    </div>
}
@section javascript
{
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>
    <script type="text/javascript">
        $(function() {
            $('#btnBack').click(function() {
                window.location.href = '@Url.Action("AccountManage")';
                return false;
            });
        });
    </script>
}